/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package panaderialabaguette;
import java.awt.Color;
import java.awt.Component;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;

/**
 *
 * @author oscar
 */
public class FormatoTablaProducto extends DefaultTableCellRenderer{

    int stock = 3 ; //indica la columna que contiene el stock de un producto
    int stockNulo = 0; //indica que no productos en stock

    @Override
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
        super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);


       this.setBackground(null);
       this.setForeground(null);

        if (isSelected)
        {
            this.setOpaque(true);
            this.setBackground(table.getSelectionBackground());
        }


        int celda_stock = Integer.parseInt(table.getValueAt(row, stock).toString());

        if (celda_stock == stockNulo)
        {
            this.setOpaque(true);
            this.setBackground(Color.lightGray);
            this.setForeground(Color.white);
        }

            return this;
        }

    }



